package com.wuhunyu.security;

import com.wuhunyu.commonutils.result.CommonResult;
import com.wuhunyu.servicebase.result.ResponseUtil;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 未授权的统一处理方式
 *
 * @author wuhunyu
 */
public class UnauthorizedEntryPoint implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) {
        ResponseUtil.out(response, CommonResult.error("未授权异常"));
    }
}
